function KDWebSocket(url, options) {
	this.ws = new SockJS(url);
	var defaults = {
		onopen : null,// 打开连接
		onmsg : null,// 收到消息监听
		onerror : null,// 错误
		onclose : null
	// 关闭
	// 关闭
	};
	this.options = $.extend(defaults, options);
}
KDWebSocket.prototype.send = function(data){
	var _this = this;
	_this.ws.send(data);
};
KDWebSocket.prototype.run = function() {
	var _this = this;
	// 打开
	_this.ws.onopen = function() {
		if ($.isFunction(_this.options.onopen)) {
			_this.options.onopen.call(_this.options.onopen);
		}
		;
	};
	// 接收消息
	_this.ws.onmessage = function(event) {
		var data = eval('(' + event.data + ')');
		if ($.isFunction(_this.options.onmsg)) {
			_this.options.onmsg.call(_this.options.onmsg, data);
		}
	};
	// 错误
	_this.ws.error = function(event) {
		if ($.isFunction(_this.options.onerror)) {
			_this.options.onerror.call(_this.options.onerror, event);
		}
		;
	};
	// 关闭
	_this.ws.onclose = function(event) {
		if ($.isFunction(_this.options.onclose)) {
			_this.options.onerror.call(_this.options.onclose, event);
		}
		;
	};
}
function KDStompWebSocket(url, options) {
	this.ws = new SockJS(url);
	this.stompClient = Stomp.over(this.ws);
	var defaults = {
		onopen : null,// 打开连接
		onmsg : null,// 收到消息监听
		onerror : null,// 错误
		onclose : null
	};
	this.options = $.extend(defaults, options);
}
/**
 * 
 */
KDStompWebSocket.prototype.run = function() {
	var _self = this;
	// 打开连接
	_self.stompClient.connect('', '', function(frame) {
		//用户超限信息订阅
		_self.stompClient.subscribe('/user/owner/overinfo/' + userId, function(data) {
			console.log(new Date().format("yyyy-MM-dd hh:mm:ss")
					+ JSON.parse(data.body));
		},function(msg) {

		});
	});
}
/**
 * websocket消息发送
 * 
 * @param url
 *            发送的URL后台，对应后台的@messageMapping
 * @param data
 *            发送的数据
 */
KDStompWebSocket.prototype.send = function(url, data) {
	var _self = this;
	_self.stompClient.send(url, {}, data);
}
